// Learn TypeScript:
//  - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html

const {ccclass, property} = cc._decorator;

@ccclass
export default class NewClass extends cc.Component {

    @property(cc.Label)
    label: cc.Label = null;
	
	
	@property(cc.Prefab)
    dog: cc.Prefab = null;
	
	@property(cc.Node)
    layerNode: cc.Node = null;
	

    @property
    text: string = 'hello';
	
	
	@property
	i: number = 0;
	

    // LIFE-CYCLE CALLBACKS:

    onLoad () {
		//this.layerNode.x
		cc.log(this.layerNode.x)
		
		
		
		//cc.log(this.dog.x)
		//var node = cc.instantiate(this.dog);
		
		//this.layerNode.addChild(node)
		
		
		
		this.layerNode.x=100
		this.layerNode.y=100
		
		for(var i=0;i<=2;i++){
		
			//cc.log(i)
			let node: number[] = [];  //声明数组 不赋值
			
			node[i] = cc.instantiate(this.dog);
			
			node[i].x=i*100
			node[i].y=i*100
			
			
			node[i].width=50
			node[i].height=50
			
			cc.log(node[i].scale)
			node[i].scale=cc.v2(3, 3)
			
			
			cc.log(node[i])
		
			//var node[i] = cc.instantiate(this.dog);
			//cc.log(node[i])
			
			this.layerNode.addChild(node[i])
			
		
			
		}
		
	
	
	
	}

    start () {

    }
	
		
     update (dt) {
	 
		
		this.i=this.i+1
		cc.log(this.i)
		
		//cc.log(this.i%2)
		
		if(this.i>50){
			this.layerNode.active=false
			
			
		
		}
		if(this.i<200&&this.i>100){
			this.layerNode.active=true
			this.i=0
		}
	 
	 }
}
